<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.*" %>
<html>
<head>
    <title>delete</title>
</head>
<body>
<%
    int curpage = 1;
    if (request.getParameter("page") != null) {
        String pg = request.getParameter("page");
        curpage = Integer.parseInt(pg);
    }
    String name = "";
    String worknumber = "";
    String department = "";
    String worktime = "";
    String profession = "";
    if (request.getParameter("name") != null) name = request.getParameter("name");
    if (request.getParameter("worknumber") != null) worknumber = request.getParameter("worknumber");
    if (request.getParameter("department") != null) department = request.getParameter("department");
    if (request.getParameter("worktime") != null) worktime = request.getParameter("worktime");
    if (request.getParameter("profession") != null) profession = request.getParameter("profession");

    String id = request.getParameter("id");
    Connection conn =(Connection)session.getAttribute("Connection");
    String sql = "delete from people where id=" + id;
    PreparedStatement preparedStatement = conn.prepareStatement(sql);
    int res = preparedStatement.executeUpdate();
    if (res > 0) {
        out.println("删除数据成功");
        //String url_next = "person_list.jsp?page=" + curpage + "&name=" + name + "&worknumber=" + worknumber + "&department=" + department + "&worktime=" + worktime + "&profession=" + profession;
        request.getRequestDispatcher("person_list.jsp").forward(request, response);
    } else {
        out.println("删除数据失败");
        response.setHeader("refresh", "3;person_list.jsp");
    }

//    preparedStatement.close();
//    conn.close();
%>
</body>
</html>
